package model;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

/**
 * 
 * @author Mathias
 */
public class TombStone
{
    private int
            id,
            theRow,
            theNumber,
            nameCharacterCount,
            numNamesRoomFor,
            morticianCommissionNo;
    private double commision;
    private String
            area,
            font;
    private ArrayList<String>
            oldName,
            inscription;
    private boolean
            cuffin,
            repaint;
    private CustomerSpecified mortician;
    private GraveYard graveYard;
    private ArrayList<ActionListener> listeners;

    public TombStone(int id, int theRow, int theNumber, int nameCharacterCount, int numNamesRoomFor, double commision, String area, ArrayList<String> oldName, 
                        ArrayList<String> inscription, String font, boolean cuffin, boolean repaint, CustomerSpecified mortician, GraveYard graveYard, int morticianCommissionNo)
    {
        this.id = id;
        this.theRow = theRow;
        this.theNumber = theNumber;
        this.nameCharacterCount = nameCharacterCount;
        this.numNamesRoomFor = numNamesRoomFor;
        this.commision = commision;
        this.area = area;
        this.oldName = oldName;
        this.inscription = inscription;
        this.font = font;
        this.cuffin = cuffin;
        this.repaint = repaint;
        this.mortician = mortician;
        this.graveYard = graveYard;
        this.morticianCommissionNo = morticianCommissionNo;
        listeners = new ArrayList();
        notifyListeners();
    }

    public TombStone()
    {
        oldName = new ArrayList();
        inscription = new ArrayList();
        mortician = new CustomerSpecified();
        graveYard = new GraveYard();
        listeners = new ArrayList();
        reset();
    }
    
    public void reset()
    {
        id = 0;
        theRow = 0;
        theNumber = 0;
        nameCharacterCount = 0;
        numNamesRoomFor = 0;
        commision = 15;
        area = "";
        oldName.clear();
        inscription.clear();
        font = "";
        cuffin = false;
        repaint = false;
        morticianCommissionNo = 0;
        mortician.reset();
        graveYard.reset();
        listeners.clear();
        notifyListeners();
    }

    public int getId()
    {
        return id;
    }

    public void setId(int id)
    {
        this.id = id;
        notifyListeners();
    }

    public int getTheRow()
    {
        return theRow;
    }

    public void setTheRow(int theRow)
    {
        this.theRow = theRow;
        notifyListeners();
    }

    public int getTheNumber()
    {
        return theNumber;
    }

    public void setTheNumber(int theNumber)
    {
        this.theNumber = theNumber;
        notifyListeners();
    }

    public int getNameCharacterCount()
    {
        return nameCharacterCount;
    }

    public int getNumNamesRoomFor()
    {
        return numNamesRoomFor;
    }

    public void setNumNamesRoomFor(int numNamesRoomFor)
    {
        this.numNamesRoomFor = numNamesRoomFor;
        notifyListeners();
    }

    public void setNameCharacterCount(int nameCharacterCount)
    {
        this.nameCharacterCount = nameCharacterCount;
        notifyListeners();
    }

    public double getCommision()
    {
        return commision;
    }

    public void setCommision(double commision)
    {
        this.commision = commision;
        notifyListeners();
    }

    public String getArea()
    {
        return area;
    }

    public void setArea(String area)
    {
        this.area = area;
        notifyListeners();
    }

    public ArrayList<String> getOldName()
    {
        return oldName;
    }

    public void setOldName(ArrayList<String> oldName)
    {
        this.oldName = oldName;
        notifyListeners();
    }
    
    public void addToOldName(String toAdd)
    {
        oldName.add(toAdd);
        notifyListeners();
    }

    public ArrayList<String> getInscription()
    {
        return inscription;
    }

    public void setInscription(ArrayList<String> inscription)
    {
        this.inscription = inscription;
        notifyListeners();
    }
    
    public void addToInscription(String toAdd)
    {
        inscription.add(toAdd);
        notifyListeners();
    }

    public String getFont()
    {
        return font;
    }

    public void setFont(String font)
    {
        this.font = font;
        notifyListeners();
    }

    public boolean isCuffin()
    {
        return cuffin;
    }

    public void setCuffin(boolean cuffin)
    {
        this.cuffin = cuffin;
        notifyListeners();
    }

    public boolean isRepaint()
    {
        return repaint;
    }

    public void setRepaint(boolean repaint)
    {
        this.repaint = repaint;
        notifyListeners();
    }

    public CustomerSpecified getMortician()
    {
        return mortician;
    }

    public void setMortician(CustomerSpecified mortician)
    {
        this.mortician = mortician;
        notifyListeners();
    }

    public GraveYard getGraveYard()
    {
        return graveYard;
    }

    public void setGraveYard(GraveYard graveYard)
    {
        this.graveYard = graveYard;
        notifyListeners();
    }

    public int getMorticianCommissionNo()
    {
        return morticianCommissionNo;
    }

    public void setMorticianCommissionNo(int morticianCommissionNo)
    {
        this.morticianCommissionNo = morticianCommissionNo;
        notifyListeners();
    }

    public ArrayList<ActionListener> getListeners()
    {
        return listeners;
    }

    public void setListeners(ArrayList<ActionListener> listeners)
    {
        this.listeners = listeners;
    }
    
    public void addListener(ActionListener listener) 
    {
        listeners.add(listener);
    }

    private void notifyListeners() 
    {
        ActionEvent event = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Something changed");
        for (ActionListener listener : listeners) 
        {
            listener.actionPerformed(event);
        }
    }
}